package com.plian.system.dao.sys.per;

import com.plian.Tools.pagedata.PageData;
import com.plian.system.dao.DaoSupport;
import org.springframework.stereotype.Component;

import javax.annotation.Resource;
import java.util.List;

@Component
public class PerUserDao {
    @Resource(name = "daoSupport")
    private DaoSupport dao;
    /**
     * 新增非企业权限
     */
    public void PerUserConfig(List<PageData> list) throws Exception {
        dao.save("PerUserMapper.PerUserConfig",list);
    }
    /**
     * 根据用户Id删除相关权限
     * @param userId
     * @throws Exception
     */
    public void del_PerUser(String userId) throws Exception {
        dao.delete("PerUserMapper.del_PerUser",userId);
    }
    /**
     * 根据用户id查询权限
     * @param userId
     * @throws Exception
     * @return
     */
    public List<PageData> queryPerUser(String userId) throws Exception {
        return (List<PageData>) dao.findForList("PerUserMapper.queryPerUser",userId);
    }

    /**
     * 根据连接查询当前用户,链接下的按钮权限
     * @param pd)
     * @return
     */
    public List<PageData> queryBtn(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PerUserMapper.queryBtn",pd);

    }

    /**
     * 查询菜单树
     * @param userId
     * @return
     */
    public List<PageData> getMenu(String userId) throws Exception {
        return (List<PageData>) dao.findForList("PerUserMapper.getMenu",userId);
    }
    /**
     *根据前端路由查询用户
     * @param pd
     * @return
     * @throws Exception
     */
    public List<PageData> getUrlUser(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PerUserMapper.getUrlUser",pd);
    }
    public List<PageData> getUsers(PageData pd) throws Exception {
        return (List<PageData>) dao.findForList("PerUserMapper.getUsers",pd);
    }
}
